package com.example.Controller;

import com.example.Model.City;
import com.example.Reprository.CityDao;
import com.example.Service.CityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by Administrator on 2017/5/3.
 */
@RestController
public class CityController {
    @Autowired
    CityService cityService;
    @RequestMapping(value = "/api/city/{id}",method = RequestMethod.GET)
    public City findOen(@PathVariable("id")Long id){
        return cityService.findOen(id);
    }
    @RequestMapping(value = "/api/city",method = RequestMethod.GET)
    public List<City> findAllCity(){

        return (List)cityService.findAll();
    }
    @RequestMapping(value = "/api/city",method = RequestMethod.POST)
    public void createCity(@RequestBody City city) {
        cityService.saveCity(city);

    }
    @RequestMapping(value = "/api/city/city")
    public List<City> getList(){
        return  cityService.getList();
    }

}
